<html>
<head><meta charset="utf-8"><title>Rust&#x27;s error message improvements over time · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Rust&#x27;s.20error.20message.20improvements.20over.20time.html">Rust&#x27;s error message improvements over time</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="195455462"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Rust%27s%20error%20message%20improvements%20over%20time/near/195455462" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> XAMPPRocky <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Rust&#x27;s.20error.20message.20improvements.20over.20time.html#195455462">(Apr 27 2020 at 18:13)</a>:</h4>
<p>Hey, I was writing a post about how Rust has improved over time, and one thing I wanted to show how much the error messages have improved. I was wondering if anyone had good specific examples of common mistakes that used to emit a confusing error message, and is now is much more clear?</p>



<a name="195455577"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Rust%27s%20error%20message%20improvements%20over%20time/near/195455577" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Léo Lanteri Thauvin <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Rust&#x27;s.20error.20message.20improvements.20over.20time.html#195455577">(Apr 27 2020 at 18:14)</a>:</h4>
<p>You could probably navigate through the closed <code>D-*</code> labeled issues?</p>



<a name="195456118"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Rust%27s%20error%20message%20improvements%20over%20time/near/195456118" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> XAMPPRocky <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Rust&#x27;s.20error.20message.20improvements.20over.20time.html#195456118">(Apr 27 2020 at 18:19)</a>:</h4>
<p>Ah, there's literally a confusing category, thanks!</p>



<a name="195457162"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Rust%27s%20error%20message%20improvements%20over%20time/near/195457162" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Rust&#x27;s.20error.20message.20improvements.20over.20time.html#195457162">(Apr 27 2020 at 18:28)</a>:</h4>
<p>one of the big improvements is the formatting IMO</p>
<div class="codehilite"><pre><span></span><span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">String</span>::<span class="n">new</span><span class="p">();</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">_a</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="n">a</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">_b</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">a</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="n">std</span>::<span class="n">mem</span>::<span class="n">drop</span><span class="p">(</span><span class="n">_a</span><span class="p">);</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>


<p>current nightly: (missing colors here)</p>
<div class="codehilite"><pre><span></span>error[E0505]: cannot move out of `a` because it is borrowed
 --&gt; src/main.rs:4:14
  |
3 |     let _a = &amp;mut a;
  |              ------ borrow of `a` occurs here
4 |     let _b = a;
  |              ^ move out of `a` occurs here
5 |     std::mem::drop(_a);
  |                    -- borrow later used here

error: aborting due to previous error
</pre></div>


<p>1.0.0:</p>
<div class="codehilite"><pre><span></span>src/main.rs:4:9: 4:11 error: cannot move out of `a` because it is borrowed
src/main.rs:4     let _b = a;
                      ^~
src/main.rs:3:19: 3:20 note: borrow of `a` occurs here
src/main.rs:3     let _a = &amp;mut a;
                                ^
error: aborting due to previous error
</pre></div>



<a name="195458513"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Rust%27s%20error%20message%20improvements%20over%20time/near/195458513" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Rust&#x27;s.20error.20message.20improvements.20over.20time.html#195458513">(Apr 27 2020 at 18:39)</a>:</h4>
<p>This seems like the kind of thing you could ask on URLO and get tons of people responding with their favorite changes.</p>



<a name="195458722"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Rust%27s%20error%20message%20improvements%20over%20time/near/195458722" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Rust&#x27;s.20error.20message.20improvements.20over.20time.html#195458722">(Apr 27 2020 at 18:42)</a>:</h4>
<p><span class="user-mention" data-user-id="219696">@XAMPPRocky</span> yeah, I'd recommend a URLO post -- there's also a blog post from 2016 or 2017 I think about the new diagnostic format that <span class="user-mention" data-user-id="216206">@Bastian Kauschke</span> references</p>



<a name="195458772"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Rust%27s%20error%20message%20improvements%20over%20time/near/195458772" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Rust&#x27;s.20error.20message.20improvements.20over.20time.html#195458772">(Apr 27 2020 at 18:42)</a>:</h4>
<p>the D-* label is very recent, circa early 2020 I think</p>



<a name="195459094"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Rust%27s%20error%20message%20improvements%20over%20time/near/195459094" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Rust&#x27;s.20error.20message.20improvements.20over.20time.html#195459094">(Apr 27 2020 at 18:45)</a>:</h4>
<p>How far back do you want to go?</p>



<a name="195459122"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Rust%27s%20error%20message%20improvements%20over%20time/near/195459122" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Rust&#x27;s.20error.20message.20improvements.20over.20time.html#195459122">(Apr 27 2020 at 18:45)</a>:</h4>
<p>Anything pre 18 is not as well categorized, but A-diagnostics existed</p>



<a name="195459141"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Rust%27s%20error%20message%20improvements%20over%20time/near/195459141" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Rust&#x27;s.20error.20message.20improvements.20over.20time.html#195459141">(Apr 27 2020 at 18:45)</a>:</h4>
<p><code>~T</code></p>



<a name="195459181"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Rust%27s%20error%20message%20improvements%20over%20time/near/195459181" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Rust&#x27;s.20error.20message.20improvements.20over.20time.html#195459181">(Apr 27 2020 at 18:46)</a>:</h4>
<p>Also look at my PRs I would say <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="195459601"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Rust%27s%20error%20message%20improvements%20over%20time/near/195459601" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Rust&#x27;s.20error.20message.20improvements.20over.20time.html#195459601">(Apr 27 2020 at 18:48)</a>:</h4>
<p>One thing that I haven't had the time to do is use rustup to get every stable rustc, run all the UI test suite and pipe the output to save it as colorized html</p>



<a name="195459643"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Rust%27s%20error%20message%20improvements%20over%20time/near/195459643" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Rust&#x27;s.20error.20message.20improvements.20over.20time.html#195459643">(Apr 27 2020 at 18:49)</a>:</h4>
<p>That way you can make the progression of changes for code we accept today over time</p>



<a name="195459762"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Rust%27s%20error%20message%20improvements%20over%20time/near/195459762" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Rust&#x27;s.20error.20message.20improvements.20over.20time.html#195459762">(Apr 27 2020 at 18:50)</a>:</h4>
<p>And rub some magic animated GIF on that ;-) (there's also a powerpoint transition that does that...)</p>



<a name="195459819"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Rust%27s%20error%20message%20improvements%20over%20time/near/195459819" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> XAMPPRocky <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Rust&#x27;s.20error.20message.20improvements.20over.20time.html#195459819">(Apr 27 2020 at 18:50)</a>:</h4>
<p><span class="user-mention" data-user-id="119031">@Esteban Küber</span> 1.0.0</p>



<a name="195459993"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Rust%27s%20error%20message%20improvements%20over%20time/near/195459993" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Rust&#x27;s.20error.20message.20improvements.20over.20time.html#195459993">(Apr 27 2020 at 18:52)</a>:</h4>
<p><a href="http://estebank.github.io/rust" title="http://estebank.github.io/rust">estebank.github.io/rust</a> has a slide only for e0308 if you go right enough and then down</p>



<a name="195460015"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Rust%27s%20error%20message%20improvements%20over%20time/near/195460015" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Rust&#x27;s.20error.20message.20improvements.20over.20time.html#195460015">(Apr 27 2020 at 18:52)</a>:</h4>
<p>But I did that by hand</p>



<a name="195460059"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Rust%27s%20error%20message%20improvements%20over%20time/near/195460059" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> XAMPPRocky <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Rust&#x27;s.20error.20message.20improvements.20over.20time.html#195460059">(Apr 27 2020 at 18:52)</a>:</h4>
<p>I found a pretty good one.</p>
<div class="codehilite"><pre><span></span><span class="k">use</span><span class="w"> </span><span class="n">std</span>::<span class="n">io</span>::<span class="n">Write</span><span class="p">;</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">trait_obj</span><span class="p">(</span><span class="n">w</span>: <span class="kp">&amp;</span><span class="nc">Write</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">generic</span><span class="p">(</span><span class="n">w</span><span class="p">);</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">generic</span><span class="o">&lt;</span><span class="n">W</span>: <span class="nc">Write</span><span class="o">&gt;</span><span class="p">(</span><span class="n">_w</span>: <span class="kp">&amp;</span><span class="nc">W</span><span class="p">)</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
</pre></div>


<p><a href="/user_uploads/4715/zfZWIly-JFUo42eFd5-Ft9ed/Screenshot-2020-04-27-at-20.49.36.png" title="Screenshot-2020-04-27-at-20.49.36.png">1.2.0 error message</a> </p>
<div class="message_inline_image"><a href="/user_uploads/4715/zfZWIly-JFUo42eFd5-Ft9ed/Screenshot-2020-04-27-at-20.49.36.png" title="1.2.0 error message"><img src="/user_uploads/4715/zfZWIly-JFUo42eFd5-Ft9ed/Screenshot-2020-04-27-at-20.49.36.png"></a></div><p><a href="/user_uploads/4715/P8ShaD5yAUGav6uJuP2_xGgv/Screenshot-2020-04-27-at-20.50.12.png" title="Screenshot-2020-04-27-at-20.50.12.png">1.43.0 error message</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/P8ShaD5yAUGav6uJuP2_xGgv/Screenshot-2020-04-27-at-20.50.12.png" title="1.43.0 error message"><img src="/user_uploads/4715/P8ShaD5yAUGav6uJuP2_xGgv/Screenshot-2020-04-27-at-20.50.12.png"></a></div>



<a name="195460122"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Rust%27s%20error%20message%20improvements%20over%20time/near/195460122" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Rust&#x27;s.20error.20message.20improvements.20over.20time.html#195460122">(Apr 27 2020 at 18:53)</a>:</h4>
<p>If you wait a week it should be even better (I have some bounds improvements waiting review)</p>



<a name="195460275"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Rust%27s%20error%20message%20improvements%20over%20time/near/195460275" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Rust&#x27;s.20error.20message.20improvements.20over.20time.html#195460275">(Apr 27 2020 at 18:54)</a>:</h4>
<p>Anything that added help is likely to be a good start. Also, I know that the borrow checker errors improved a lot, and that's a combo of display and content improvements.</p>



<a name="195460486"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Rust%27s%20error%20message%20improvements%20over%20time/near/195460486" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Rust&#x27;s.20error.20message.20improvements.20over.20time.html#195460486">(Apr 27 2020 at 18:56)</a>:</h4>
<p>I would look around the UI test stdout files that look nice now and try them on older compilers if you don't want to look at PRs or closed tickets</p>



<a name="195460808"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Rust%27s%20error%20message%20improvements%20over%20time/near/195460808" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Rust&#x27;s.20error.20message.20improvements.20over.20time.html#195460808">(Apr 27 2020 at 18:59)</a>:</h4>
<p>This is a good example as well, I think <a href="https://godbolt.org/z/wieST7" title="https://godbolt.org/z/wieST7">https://godbolt.org/z/wieST7</a></p>



<a name="195461058"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Rust%27s%20error%20message%20improvements%20over%20time/near/195461058" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> XAMPPRocky <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Rust&#x27;s.20error.20message.20improvements.20over.20time.html#195461058">(Apr 27 2020 at 19:01)</a>:</h4>
<p>Definitely <a href="/user_uploads/4715/v6eB82tY3qy4XhMOTkOmLx98/Screenshot-2020-04-27-at-21.01.08.png" title="Screenshot-2020-04-27-at-21.01.08.png">Screenshot-2020-04-27-at-21.01.08.png</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/v6eB82tY3qy4XhMOTkOmLx98/Screenshot-2020-04-27-at-21.01.08.png" title="Screenshot-2020-04-27-at-21.01.08.png"><img src="/user_uploads/4715/v6eB82tY3qy4XhMOTkOmLx98/Screenshot-2020-04-27-at-21.01.08.png"></a></div>



<a name="195461230"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Rust%27s%20error%20message%20improvements%20over%20time/near/195461230" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Rust&#x27;s.20error.20message.20improvements.20over.20time.html#195461230">(Apr 27 2020 at 19:03)</a>:</h4>
<p>snice</p>



<a name="195463089"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Rust%27s%20error%20message%20improvements%20over%20time/near/195463089" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sebastian Malton <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Rust&#x27;s.20error.20message.20improvements.20over.20time.html#195463089">(Apr 27 2020 at 19:19)</a>:</h4>
<p>My recent PR to add an error that says that <code>fn main()</code> cannot be <code>async</code> landed recently. Before that it only said that <code>main can only return types that implement Termination</code></p>



<a name="195474852"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Rust%27s%20error%20message%20improvements%20over%20time/near/195474852" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> marmeladema <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Rust&#x27;s.20error.20message.20improvements.20over.20time.html#195474852">(Apr 27 2020 at 21:04)</a>:</h4>
<p>For me its nll error messages about lifetimes that is a game changer.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>